/*!
 * Jodit Editor (https://xdsoft.net/jodit/)
 * Released under MIT see LICENSE.txt in the project root for license information.
 * Copyright (c) 2013-2020 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
 */

@import (reference) '../../../styles/variables';
@import (reference) '../../../styles/mixins';

.button-size(@size) {
	@plus: (@size - 4px) * 2;

	min-width: @size + @plus;
	height: @size + @plus;

	.jodit-icon {
		width: @size;
		height: @size;
	}

	button {
		appearance: none;
		min-width: @size + @plus;
		height: @size + @plus;
	}
}

.jodit-ui-button-interaction() {
	&:hover:not([disabled]) {
		background-color: var(--color-button-background-hover);
		outline: 0;
		opacity: 1;
	}

	&:active:not([disabled]),
	&[aria-pressed='true']:not([disabled]) {
		background-color: var(--color-button-background-hover_opacity40);
		outline: 0;
	}

	&[aria-pressed='true']:hover:not([disabled]) {
		background-color: var(--color-button-background-hover_opacity60);
	}

	&[disabled] {
		opacity: 0.3;
		pointer-events: none;
	}
}

.jodit-ui-button-icon-text {
	&__icon {
		display: none;

		&:not(:empty) {
			display: inline-flex;
		}
	}

	&__text {
		display: none;

		&:not(:empty) {
			.font();

			display: inline-flex;
			flex: 1;
			justify-content: center;
		}
	}

	&_context_menu &__text {
		justify-content: left;
		padding-left: var(--padding-default);
		position: relative;

		&::before {
			content: '';
			position: absolute;
			border-left: 1px solid var(--color-border);
			height: 35px;
			top: calc(var(--padding-default) * -1);
			left: 0;
		}
	}

	&__icon:not(:empty) + &__text:not(:empty) {
		margin-left: var(--padding-default);
	}

	&__icon:empty + &__text:not(:empty) {
		padding: 0 var(--padding-default);
	}
}

.jodit-ui-button_clear {
	appearance: none;
	padding: 0;
	position: relative;
	text-align: center;
	background: 0 0;
	text-transform: none;
	font-style: normal;
	box-shadow: none;
	border: 0;
	box-sizing: border-box;
	user-select: none;
	background-clip: padding-box;
	text-decoration: none;
	outline: 0;
}

.jodit-ui-button-sizes {
	.button-size(@icon-middle-size);

	&_size {
		&_tiny {
			.button-size(@icon-tiny-size);
		}

		&_xsmall {
			.button-size(@icon-xsmall-size);
		}

		&_small {
			.button-size(@icon-small-size);
		}

		&_large {
			.button-size(@icon-large-size);
		}
	}
}

.jodit-ui-button-statuses {
	&_status_default {
		.jodit_status(#d8d8d8, #212529, #c9cdd1, #212529, #dae0e5, #212529);
	}

	&_status_primary {
		.jodit_status(#007bff, #fff, #0069d9, #fff, #0062cc, #fff);
	}

	&_status_secondary {
		.jodit_status(#d8d8d8, #212529, #c9cdd1, #212529, #dae0e5, #212529);
		border-radius: 0;
	}

	&_status_success {
		.jodit_status(#28a745, #fff, #218838, #fff, #1e7e34, #fff);
	}

	&_status_danger {
		.jodit_status(#dc3545, #fff, #c82333, #fff, #bd2130, #fff);
	}
}

.jodit-ui-button-style {
	display: inline-flex;
	justify-content: center;
	align-items: center;

	padding: 0 var(--padding-default);
	border-radius: var(--border-radius-default);
}

.jodit-ui-button {
	.jodit-ui-button_clear();

	.jodit-ui-button-style();

	.jodit-ui-button-interaction();

	.jodit-ui-button-sizes();

	.jodit-ui-button-icon-text();

	&:focus:not([disabled]) {
		outline: 1px dashed var(--color-background-selection);
	}

	.jodit-ui-button-statuses();
}
